#!/sbin/openrc-run
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

NAME="amavisd-milter"
DAEMON="/usr/sbin/${NAME}"

depend() {
        use logger dns amavis sendmail
}

start() {
        ebegin "Starting ${NAME}"
        start-stop-daemon --start --quiet --exec "${DAEMON}" -p "${PIDFILE}" --user amavis -- ${DOPTIONS}
        eend $? "Failed to start ${NAME}"
}

stop() {
        ebegin "Stopping ${NAME}"
        start-stop-daemon --stop --name "${NAME}"
        eend $? "Failed to stop ${NAME}"
}

restart() {
        svc_stop
        # needed to avoid potential mi_stop errors
        sleep 4
        svc_start
}
